package com.skytech.component.crawler.quartz;

import com.skytech.component.crawler.scratch.TaskStatusDAO;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class QuartzJob implements Job {


    private static final Logger logger= LoggerFactory.getLogger(QuartzJob.class);

    @Autowired
    private UpdateCronTask updateCronTask;




    /**
     * 执行 job
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext)  {
        try{
            JobDataMap map =   jobExecutionContext.getJobDetail().getJobDataMap();
            String id= (String) map.get("params");

            updateCronTask.startOneTask(id);

        }catch (Exception e){
            logger.error("QuartzJob execute error",e);
        }
    }

}

